package com.chinasofti.service;

import com.chinasofti.dao.EmployeeDao;
import com.chinasofti.vo.Employee;

public class EmployeeService {

    private Employee loginsemployee;
    private EmployeeDao dao = new EmployeeDao();



    public int register(Employee employee){

        int flag = 0;
        Employee e = dao.selectByUsername(employee.getUsername());
        if(e ==null){
            flag = 1;
            dao.insert(employee);
        }
        return flag;
    }


    public int login(String username,String pwd){
        int flag = 3;
        Employee e = dao.selectBynamePwd(username,pwd);
        if (e!=null){
            loginsemployee = e;
            String status = e.getStatus();
            if (status!=null&& status.equals("1")){
                flag = 1;
            }
            if (status!=null&& status.equals("0")){
                flag = 0;
            }
            if (status!=null&& status.equals("2")){
                flag = 2;
            }
        }
        return flag;
    }
    public Employee getLoginsemployee(){
        return loginsemployee;
    }
}
